package com.learn.rmi;

import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.RemoteException;

/**
 * @author wangxing
 * @version 2020/7/4 13:27 Administrator
 */
public class RmiServer {
    public static void main(String[] args) {
        IUserService service = null;
        try {
            service = new UserServiceImpl();
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        try {
            Naming.bind("rmi://192.168.1.2:8888/UserService", service);
            System.out.println("服务已经发布");
            System.in.read();
        } catch (AlreadyBoundException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        ;
    }
}
